<?php
namespace Home\Controller;
use Think\Controller;
class UserController extends Controller {
	public function index(){
		$this->display();
	}

	public function send(){
		if (!$weObj =getCache('weObj')) {
			$options = array(
	 		   'token'=>c('wxtoken'), //填写你设定的key
	 		   'encodingaeskey'=>c('encodingaeskey'), //填写加密用的EncodingAESKey
			   'appid'=>c('appid'), //填写高级调用功能的app id, 请在微信开发模式后台查询
	  		   'appsecret'=>c('appsecret') //填写高级调用功能的密钥
	  		   );
		 	$weObj = new \Org\Net\Wechat($options); //创建实例对象
		 	setCache('weObj',$weObj);			 					
		 };
		
		 $weObj->checkAuth($appid,$appsecret);
		 $data =array ("touser"=>"oOLr4s-9-oVGU9w31r1dX8nDYVJ0",
		 	"template_id"=>"LOC6NmMskWqBS2E6kTAhIyjbRh0m1TggpR4DoanMdbk",
		 	"url"=>"",
		 	"topcolor"=>"#FF0000",
		 	"data"=>array (
		 		"msgtype"=>array(
		 			"value"=>"最新比分",
								"color"=>"#000000"	 //参数颜色
								),
		 		"msgbrief"=>array (
		 			"value"=>"恒大5-3富力",
		 			"color"=>"#FF7F00"
		 			),
		 		"msgtxt"=>array (
		 			"value"=>"恒大5号张三单刀突破，绕过守门员，射入空门！",
		 			"color"=>"#333333"
		 			)
		 		)
		 	);
		 $msginfo=$weObj->sendTemplateMessage($data);
		 if ($msginfo) {var_dump($msginfo);}

		}

	}